b,d=map(int,input().split());s=d-1 while 1-s%2:s//=2 print('yneos'[pow(b,s,d)<2if d-2else 1-b%2::2])